/**
 * Created by yoyoyk on 2017/3/8.
 */
import React , {Component}from 'react';
import { Modal, Button } from 'antd';
import InputBox from '../../common/InputBox.js'
import Confirm from '../../common/Confirm'
import Select from '../../common/Select'
import UpdateUser from "./mutation/UpdateUserMutation"
import Relay from "react-relay";
import GetRolesMutation from "./mutation/GetRolesMutation"

/*系统后台>后台管理>后台人员列表>用户列表>编辑人员信息*/

export default class Editpersoninfo extends React.Component {
    constructor(props){
        super(props);
        this.state = {
            visible: false,
            phone:'',
            name:'',
            uid:'',
            depId:'',
            role:[],
            roleId:'',
        }
        this.Style={};

    }

    componentWillMount() {
        this.Style.addpersonview={
            textAlign:"center",
            display:"block",
            border:"3px solid green"
        }
        this.Style.addpersonview.width = 400;
        this.Style.addpersonview.height = 200;
        this.Style.addpersonview.fontSize = 30;
        this.Style.addpersonview={
            width:"634px",
            height:"44px",
            paddingLeft:"18px",
            lineHeight:"44px",
            display:"block",
            background:"#f2f2f2",
            marginBottom:49
        }

    }

    state = { visible: false }
    showModal = () => {
        this.setState({
            visible: true,
        });
    }
    handleOk = (e) => {
        console.log(e);
        this.setState({
            visible: false,
        });
    }
    handleCancel = (e) => {
        this.setState({
            visible: false,
        });
    }
    //修改
    createuser(){
        this.refs.selectrole.state.Defaultvalue

        Relay.Store.commitUpdate(
            new UpdateUser({
                enterpriseId: '26',
                uid: this.state.uid,
                depId: this.state.depId,
                roEnId: '26',
                roleId: this.state.roleId,
                name:this.refs.name.state.text,
                phone:this.refs.phone.state.text,
                password:this.refs.password.state.text,
            }),
            {
                onFailure: ()=>{

                },
                onSuccess: (response)=>{
                  JSON.stringify(response);
                }
            }
        );
    }

    render(){
        return (
            <div>
                <Button  type="primary" onClick={this.showModal} >编辑</Button>
                <Modal visible={this.state.visible} onOk={this.handleOk} onCancel={this.handleCancel} style={{width:"634px",height:"240px",display:"block"}} title={"编辑人员信息"}>
                    <InputBox defaultvalute="请输入手机号" titletext="手机号" space="12px" style={{width:338,height:30,borderColor:"#d7d7d7",color:"#999",marginTop:"20px",paddingRight:123}} ref={'phone'}/>
                    <InputBox defaultvalute="请输入姓名" titletext="姓名" space="12px" style={{width:338,height:30,borderColor:"#d7d7d7",color:"#999",marginTop:"20px",paddingRight:123}} ref={'name'}/>
                    <InputBox type="password" defaultvalute="请输入密码" titletext="密码" space="12px" style={{width:338,height:30,borderColor:"#d7d7d7",color:"#999",marginTop:"20px",paddingRight:123}} ref={'password'}/>
                    <span style={{display:"block",color:"#009dd9",marginLeft:124,marginTop:6}}>重置密码</span>
                    <Select  oArr={this.state.role} style={{width:338,height:30,display:"inlineBlock",marginTop:20,marginLeft:124}} ref={'selectrole'}/>
                    <Confirm tcontext="添加" style={{width:130,height:30,display:"block",color:"#fff",fontSize:"16px",marginTop:60,marginLeft:220}} touch={this.createuser.bind(this)}/>
                    <span style={{position:"absolute",left:470,top:6}}>(用作登陆账号)</span>
                </Modal>
            </div>
        )
    }
}



